package com.khtn.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.json.simple.JSONObject;


/**
 * The persistent class for the tours database table.
 * 
 */
@Entity
@Table(name="tours")
@NamedQuery(name="findAll", query="SELECT t FROM Tour t")
public class Tour extends AbstractModel implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="tour_id")
	private int tourId;

	@Lob
	@Column(name="tour_content")
	private String tourContent;

	@Column(name="tour_count")
	private int tourCount;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="tour_date_begin")
	private Date tourDateBegin;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="tour_date_end")
	private Date tourDateEnd;

	@Column(name="tour_name")
	private String tourName;

	@Column(name="tour_price")
	private double tourPrice;

	//bi-directional many-to-one association to Type
	@ManyToOne
	@JoinColumn(name="tour_type_id")
	private Type type1;

	//bi-directional many-to-one association to Type
	@ManyToOne
	@JoinColumn(name="tour_place_to_id")
	private Type type2;

	//bi-directional many-to-one association to Type
	@ManyToOne
	@JoinColumn(name="tour_place_from_id")
	private Type type3;

	public Tour() {
	}

	public int getTourId() {
		return this.tourId;
	}

	public void setTourId(int tourId) {
		this.tourId = tourId;
	}

	public String getTourContent() {
		return this.tourContent;
	}

	public void setTourContent(String tourContent) {
		this.tourContent = tourContent;
	}

	public int getTourCount() {
		return this.tourCount;
	}

	public void setTourCount(int tourCount) {
		this.tourCount = tourCount;
	}

	public Date getTourDateBegin() {
		return this.tourDateBegin;
	}

	public void setTourDateBegin(Date tourDateBegin) {
		this.tourDateBegin = tourDateBegin;
	}

	public Date getTourDateEnd() {
		return this.tourDateEnd;
	}

	public void setTourDateEnd(Date tourDateEnd) {
		this.tourDateEnd = tourDateEnd;
	}

	public String getTourName() {
		return this.tourName;
	}

	public void setTourName(String tourName) {
		this.tourName = tourName;
	}

	public double getTourPrice() {
		return this.tourPrice;
	}

	public void setTourPrice(double tourPrice) {
		this.tourPrice = tourPrice;
	}

	public Type getType1() {
		return this.type1;
	}

	public void setType1(Type type1) {
		this.type1 = type1;
	}

	public Type getType2() {
		return this.type2;
	}

	public void setType2(Type type2) {
		this.type2 = type2;
	}

	public Type getType3() {
		return this.type3;
	}

	public void setType3(Type type3) {
		this.type3 = type3;
	}

	@Override
	public JSONObject toJson() {
		JSONObject js = new JSONObject();
		js.put("tour_id", getTourId());
		js.put("tour_name", getTourName());
		js.put("tour_content", getTourContent());
		js.put("tour_price", getTourPrice());
		js.put("tour_date_begin", getTourDateBegin());
		js.put("tour_date_end", getTourDateEnd());
		js.put("tour_count", getTourCount());
		js.put("tour_place_from", getType3().toJson());
		js.put("tour_place_to", getType2().toJson());
		js.put("tour_type", getType1().toJson());
		return js;
	}

}